"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
exports.__esModule = true;
function greeter(person) {
    return 'Hello, ' + person.firstName + ' ' + person.lastName;
}
var user = { firstName: 'Jane', lastName: 'User' };
// document.body.innerHTML = greeter(user);
var isBig = true;
isBig = null;
console.log(isBig);
var x;
var Color;
(function (Color) {
    Color[Color["green"] = 1] = "green";
    Color[Color["blue"] = 2] = "blue";
    Color[Color["red"] = 3] = "red";
})(Color || (Color = {}));
var c = Color.green;
var d = Color[3];
console.log(c, d);
function foo() {
    // okay to capture 'a'
    return a;
}
// 不能在'a'被声明前调用'foo'
// 运行时应该抛出错误
foo();
var a;
var p = { x: 10, y: 20 };
// p.x = 30
p.desc = 'point';
// p.z = 40
function getPoint(p) {
    var point = { x: null, y: null, desc: null };
    if (p.x) {
        point.x = p.x;
    }
    if (p.y) {
        point.y = p.y;
    }
    if (p.desc) {
        point.desc = p.desc;
    }
    return point;
}
var getP = getPoint({ x: 10, y: 20 });
console.log(getP);
function printLabel(labelledObj) {
    console.log(labelledObj.label);
}
var myObj = { size: 10, label: 'Size 10 Object' };
printLabel(myObj);
var rArray = [1, 2, 3, 4];
var things = { color: 'red' };
console.log(things);
var Animal = /** @class */ (function () {
    function Animal() {
    }
    return Animal;
}());
var Fish = /** @class */ (function (_super) {
    __extends(Fish, _super);
    function Fish() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Fish.prototype.walk = function () {
        console.log('不能游泳');
    };
    return Fish;
}(Animal));
var car = /** @class */ (function () {
    function car(eyes) {
        this.eyes = eyes;
    }
    car.prototype.walk = function () {
        console.log('用轮子' + '没有' + this.eyes);
    };
    return car;
}());
/*
interface ClockConstructor {
    new (hour: number, minute: number);
}

class Clock implements ClockConstructor {
    currentTime: Date;
    constructor(h: number, m: number) { }
}
*/
/*
interface fnTest {
  test()
}

let aFn: fnTest = function () {


}
*/
var dazhon = new car(0);
dazhon.walk();
var Phone = /** @class */ (function () {
    function Phone(model, size) {
        this.model = model;
        this.size = size;
    }
    Phone.prototype.getSize = function () {
        console.log("\u624B\u673A\u5927\u5C0F\u662F" + this.size);
        var p1 = new Phone('mi', '6');
    };
    return Phone;
}());
var Mi = /** @class */ (function (_super) {
    __extends(Mi, _super);
    function Mi(model, size, miui) {
        var _this = _super.call(this, model, size) || this;
        _this.miui = miui;
        return _this;
    }
    Mi.prototype.getMiui = function () {
        console.log(this.size);
    };
    return Mi;
}(Phone));
// console.log(p1.size); // 受保护的属性无法被实例化对象以及类直接访问
var m1 = new Mi('mi', '6', 10);
// let pw = 'u'
// get uname(): string{
//   return this._uname
// }
// set uname(newName: string){
//   if(pw && pw == 'uu'){
//     this._uname = newName
//   }else{
//     console.log('密码错误')
//   }
// }
var User = /** @class */ (function () {
    function User() {
    }
    User.getUname = function () {
        return User._uname;
    };
    User._uname = 'lsc';
    return User;
}());
console.log(User._uname);
console.log(User.getUname());
// let cfn: Counter;
var cfn = function (n) {
    return true;
};
var u = new User();
console.log(typeof u);
// let add: (x: number, y?: number) => number = function (x: number, y: number) { return x + y }
// console.log(add(1));
function add(x, y) {
    var rest = [];
    for (var _i = 2; _i < arguments.length; _i++) {
        rest[_i - 2] = arguments[_i];
    }
}
// 上面函数的类型为
var addFn = add;
// 设计一个函数输入什么输出什么，且类型一致
/*
不用泛型
缺点：不能传入字符串数据
*/
function identify1(arg) {
    return arg;
}
/*
使用any
缺点：可以传入数字输出字符串
*/
function identify2(arg) {
    return arg;
}
/*
使用泛型
缺点：可以传入数字输出字符串
*/
function identify3(arg) {
    return arg;
}
var myIdentify = identify3;
var Value = /** @class */ (function () {
    function Value() {
    }
    return Value;
}());
function identify4(arg) {
    console.log(arg.length);
}
var BeeKeeper = /** @class */ (function () {
    function BeeKeeper() {
    }
    return BeeKeeper;
}());
var ZooKeeper = /** @class */ (function () {
    function ZooKeeper() {
    }
    return ZooKeeper;
}());
var Animal1 = /** @class */ (function () {
    function Animal1() {
    }
    return Animal1;
}());
var Bee = /** @class */ (function (_super) {
    __extends(Bee, _super);
    function Bee() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return Bee;
}(Animal1));
var Lion = /** @class */ (function (_super) {
    __extends(Lion, _super);
    function Lion() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return Lion;
}(Animal1));
function createInstance(c) {
    return new c();
}
console.log(createInstance(Lion).keeper.nametag);
console.log(createInstance(Bee).keeper.hasMask);
